﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DataLoad.iContact.WinClient
{
    public partial class EditForm : Form
    {
        public EditForm()
        {
            InitializeComponent();
        }

        private string _value;

        public string Value
        {
            get
            {
                return _value;
            }
        }

        private string _selectedOption;

        public string SelectedOption
        {
            get
            {
                return _selectedOption;
            }
        }

        public DialogResult Show(string caption, string[] options, string defaultValue, int selectedOption)
        {
            Text = caption;
            cbOptions.Items.Clear();
            cbOptions.Items.AddRange(options);
            cbOptions.SelectedIndex = selectedOption;

            edtValue.Text = defaultValue;

            if (ShowDialog() == DialogResult.OK)
            {
                _value = edtValue.Text;
                _selectedOption = cbOptions.Items[cbOptions.SelectedIndex].ToString();
                return DialogResult.OK;
            }
            else
            {
                _value = defaultValue;
                _selectedOption = cbOptions.Items[selectedOption].ToString();
                return DialogResult.Cancel;
            }
        }
    }
}
